{ Statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=203
  Verdict: Accepted
}
uses
	SysUtils, Math;
 
var
	i,n:longint;
	a:array[0..40] of int64;
 
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
read(n);
a[1] := 1;
a[2] := 2;
a[3] := 4;
for i:=4 to n do
	a[i] := a[i - 1] + a[i - 2] + a[i - 3];
write(a[n]);
end.